/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package net.jcdev.coolrss;

import com.apple.eawt.Application;
import com.apple.eawt.ApplicationEvent;
import com.apple.eio.FileManager;
import com.explodingpixels.macwidgets.HudWindow;
import com.sun.syndication.feed.atom.Entry;
import com.sun.syndication.feed.synd.SyndEntryImpl;
import com.sun.syndication.feed.synd.SyndFeed;
import com.sun.syndication.io.FeedException;
import com.sun.syndication.io.SyndFeedInput;
import com.sun.syndication.io.XmlReader;
import java.awt.Image;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import net.jcdev.coolrss.view.Index;
import net.jcdev.coolrss.view.IndexFrame;
import net.jcdev.coolrss.view.MacIndex;
import thinlet.swing.app.AppFrame;

/**
 *
 * @author carlos
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) throws MalformedURLException, IllegalArgumentException, FeedException, IOException {
        try {
            /*
             * SyndFeedInput input = new SyndFeedInput();
             * SyndFeed feed = input.build (new XmlReader (feedUrl));
             */
            /*SyndFeedInput input = new SyndFeedInput();
            SyndFeed feed = input.build(new XmlReader(new URL("http://www.meiobit.com/index.xml")));
            System.out.println("Feed Title: "+ feed.getTitle());
            List<SyndEntryImpl> entries = (List<SyndEntryImpl>) feed.getEntries();
            for (SyndEntryImpl entry : entries) {
            System.out.println(entry.getTitle());
            }
            System.out.println(feed.getPublishedDate());*/
            UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
        } catch (ClassNotFoundException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        } catch (UnsupportedLookAndFeelException ex) {
            Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
        }

        MacIndex macIndex = new MacIndex();
        macIndex.showMacFrame(640, 480);

        SwingUtilities.updateComponentTreeUI(macIndex);

        // Definindo o titúlo da aplicação
        macIndex.setTitle("CoolRSS");
        // Obtendo uma instância do objeto Application
        com.apple.eawt.Application a = Application.getApplication();

        // Criando a imagem de icone do Dock
        ImageIcon icon = new ImageIcon(macIndex.getClass().getResource("/net/jcdev/coolrss/resources/dock_icon.png"));

        // Definindo o ícone do Dock
        a.setDockIconImage(icon.getImage());

        // Definindo um icon badge, um texto que será exibido em uma layer acima do dock icon.
        a.setDockIconBadge("1457");

        //IndexFrame frame = new IndexFrame();
        //frame.showIndexFrame(500, 400);

    }

}
